<?php

namespace Biz\service\advertisement\position;

use Biz\cache\advertisement\CApiCounter;
use Biz\cache\advertisement\CPositionBaseInfo;
use Biz\service\advertisement\db\PositionBaseInfoCache;
use Biz\service\advertisement\db\PositionCounterCache;
use Biz\service\advertisement\db\PositionRulesCache;
use Biz\service\advertisement\db\TaskCounterCache;
use Encore\Admin\Grid;
use Encore\Admin\Widgets\Form;

class BizPositionTaskManagement extends BizPositionPageTpl
{

    public function getList(): array
    {

        $key = '1111';
        TaskCounterCache::readTask();
        dump(TaskCounterCache::run('array_sum', [10,100]));
//        TaskCounterCache::del($key);
//        dump(TaskCounterCache::cache($key));
//        TaskCounterCache::expire($key, 180);
        dump(TaskCounterCache::ttlDesc($key));

//        $key = CApiCounter::getDayKey($uid = 5204625, $position_id = 124, $date = date("Ymd"));
//        var_dump($key);
//        $key = '20230713_5204625_124_day';
////        PositionCounterCache::getInstance()->setCache($key, 1);
//        $rs = PositionCounterCache::getInstance()->getCache($key);
//        dump($rs);
////        dump(PositionCounterCache::expireAt($key, strtotime(date("23:59:59"))));
//        $rs = PositionCounterCache::ttl($key);
//        dump($rs);
//        dump(PositionCounterCache::getInstance()->getRedis()->getFullKey($key));
//        PositionBaseInfoCache::del(123);
        $cache = PositionBaseInfoCache::cache(123);
        dump($cache);
//        $time = PositionBaseInfoCache::expire(123, 3600);
//        dump($time);
//        $time = PositionBaseInfoCache::ttl(123);
//        dump($time);

//        dump(\Doraemon\service\position\PositionApi::activeRules([12052,12055,12053]));
//        $cache = PositionRulesCache::cache([12052,12055,12053]);
//        dump($cache);


        return [];
    }

    public function getTotal(): int
    {
        // TODO: Implement getTotal() method.
        return TaskCounterCache::total();
    }

    public function getGrid(Grid $grid)
    {
        // TODO: Implement getGrid() method.
    }

    public function getForm(Form $form)
    {
        // TODO: Implement getForm() method.
    }

    public function getFormInfo($id)
    {
        // TODO: Implement getFormInfo() method.
    }

    public function save($input)
    {
        // TODO: Implement save() method.
    }

    public function delete($id)
    {
        // TODO: Implement delete() method.
    }
}